package com.itheima.sh.indent.Controller;

import com.itheima.sh.indent.service.IndentService;
import com.itheima.sh.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/indent")
//@Slf4j
public class IndentController {

    @Autowired
    private IndentService indentService;

//    @Value("${server.port}")
//    private String port;
    /**
     * 根据主键用户名查询订单列表
     *
     * @param username 登录用户名
     * @return
     */
    // http://ip:port/order/findOrderByUserId/itcast
//    @GetMapping("findOrderByUserId/{username}")
//    public List<Order> findOrderByUserId(@PathVariable("username") String username){
    // http://ip:port/order/findOrderByUserId?username=itcast
    @GetMapping("/findOrderByUserId")
    public List<Order> findOrderByUserId(@RequestParam("username") String username) {

//        System.out.println(" OrderController PORT : "+ port);
        return indentService.findOrderByUserId(username);
    }
}